#include "Tree.h"

BTNode* buyNode(char x)
{
	BTNode* node = (BTNode*)malloc(sizeof(BTNode));
	node->data = x;
	node->left = node->right = NULL;
	return node;
}

BTNode* createBinaryTree()
{
	BTNode* nodeA = buyNode('A');
	BTNode* nodeB = buyNode('B');
	BTNode* nodeC = buyNode('C');
	BTNode* nodeD = buyNode('D');
	BTNode* nodeE = buyNode('E');
	BTNode* nodeF = buyNode('F');
	nodeA->left = nodeB;
	nodeA->right = nodeC;
	nodeB->left = nodeD;
	nodeC->left = nodeE;
	nodeC->right = nodeF;
	return nodeA;
}

void test01()
{
	BTNode* root = createBinaryTree();
	preOrder(root);
	printf("\n");
	inOrder(root);
	printf("\n");
	postOrder(root);
	printf("\n");
	levelOrder(root);
	printf("\n");
	printf("size: %d\n", BinaryTreeSize(root));
	printf("leaf: %d\n", BinaryTreeLeafSize(root));
	printf("level: %d\n", BinaryTreeLevelKSize(root, 2));
	printf("depth: %d\n", BinaryTreeDepth(root));
	BTNode* ret = BinaryTreeFind(root, 'E');
	if (ret != NULL)
		printf("find: %c\n", ret->data);
	else
		printf("find: NULL\n");
	BinaryTreeDestory(&root);
}

int main()
{
	test01();
	return 0;
}

